﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace xna_game_engine.source
{
    public class State_CharInfo : State_Base
    {
        // Members
        CGameScreen mScreen;
        private float mXPos, mYpos;

        // Functions
        public State_CharInfo(StateMachine.States Id) : base(Id)
        {
            mName = "Char Info";
            mScreen = new CGameScreen();
            mScreen.AddElement(new CScreenElementImage("screens//char_info_background", Vector2.Zero));

            // Add our event handlers...
            mEventHandlers[EventManager.Events.EVT_B_HIT] = new EventHandler(OnExit);
            mXPos = 200.0f;
            mYpos = 150.0f;
        }

        private void OnExit()
        {
            Console.WriteLine("Char Select: Transitioning to Gameplay State...");
            //GameSystems.Audio.PlaySoundCue("level_up");
            GameGlobals.StateMachine.Transition(StateMachine.States.STATE_GAMEPLAY);

        }

        // Parental Overrides (forced)
        public override void  Init()
        {
            Console.WriteLine("Char Info Init()...");
            mScreen.Init();
 	        //throw new System.NotImplementedException();
        }

        public override void Enter()
        {
            Console.WriteLine("Char Info Enter()...");
            mParent = GameGlobals.StateMachine.GetState(StateMachine.States.STATE_GAMEPLAY);
            //throw new NotImplementedException();
        }

        public override void Update(GameTime gameTime)
        {
            //mParent.Update(gameTime);
            mScreen.Update(gameTime);
            //Console.WriteLine("Main Menu Update()...");
            //throw new NotImplementedException();
        }

        public override void Exit()
        {
            Console.WriteLine("Char Info Exit()...");
            //throw new NotImplementedException();
        }

        public override void Draw()
        {
            mParent.Draw();
            mScreen.Draw();
            // Character Info
            GameSystems.Graphics.DrawText("Name: " + GameGlobals.mPlayers[0].Name, new Vector2(mXPos, mYpos), Color.White);
            //GameSystems.Graphics.DrawText("Class: " + GameGlobals.mPlayers[0].Class, new Vector2(mXPos, mYpos+25.0f), Color.White);
            //GameSystems.Graphics.DrawText("Level: " + GameGlobals.mPlayers[0].Level, new Vector2(mXPos, mYpos+50.0f), Color.White);
            GameSystems.Graphics.DrawText("Health: " + GameGlobals.mPlayers[0].CurHealth + "/" + GameGlobals.mPlayers[0].MaxHealth, new Vector2(mXPos, mYpos+75.0f), Color.White);
            //GameSystems.Graphics.DrawText("Power: " + GameGlobals.mPlayers[0].CurPower + "/" + GameGlobals.mPlayers[0].MaxPower, new Vector2(mXPos, mYpos+100.0f), Color.White);
            //GameSystems.Graphics.DrawText("Strength: " + GameGlobals.mPlayers[0].Strength, new Vector2(mXPos, mYpos+125.0f), Color.White);
            //GameSystems.Graphics.DrawText("Agility: " + GameGlobals.mPlayers[0].Agility, new Vector2(mXPos, mYpos + 150.0f), Color.White);
            //GameSystems.Graphics.DrawText("Focus: " + GameGlobals.mPlayers[0].Focus, new Vector2(mXPos, mYpos + 175.0f), Color.White);

            // Inventory
            //GameSystems.Graphics.DrawText("-------- Inventory --------", new Vector2(mXPos + 425.0f, mYpos), Color.White);
            //int count = 0;
            //foreach (string item in GameGlobals.mPlayers[0].Inventory.Keys)
            //{
            //    GameSystems.Graphics.DrawText("" + item, new Vector2(mXPos + 410.0f, mYpos + 25.0f + (25.0f * count)), Color.White);
            //    GameSystems.Graphics.DrawText("x " + GameGlobals.mPlayers[0].Inventory[item], new Vector2(mXPos + 620.0f, mYpos+25.0f + (25.0f * count)), Color.White);
            //    count++;
            //}
        }
    }
}
